The same as modulo, for whole numbers: what is left over after dividing a by b, never less than 0, and the answer is a whole number. modulo_int(-1, 5) is 4. Use it for something counted, such as which of 4 pictures is next: picture = modulo_int(picture + 1, 4).
modulo_int(a, b) -> int| Name | Type |
|---|---|
a | int |
b | int |
int
The same as modulo, for whole numbers: what is left over after dividing a by b, never less than 0, and the answer is a whole number. modulo_int(-1, 5) is 4.
Use it for something counted, such as which of four pictures comes next: picture = modulo_int(picture + 1, 4);.
var picture = 3;
picture = modulo_int(picture + 1, 4);
var back = modulo_int(-1, 4);picture goes from 3 round to 0, and back is 3.
modulo and modulo_int do the same sum. They differ in the type of the answer. modulo hands back a real, so picture = modulo(picture + 1, 4) turns picture into a real, and the next place that wants a whole number refuses it, often in another file:
Argument 4 to `draw_sprite` should be an int, but this is a real.Written with modulo_int, it cannot happen.
modulo_int(x, 5) with a real x is refused when the project is checked. Round it first with int_floor, int_ceil or int_round.
A negative b counts as its size, and a b of 0 gives 0.
One divide.
modulo and modulo_int do the same sum and differ in the TYPE of the answer, the way wrap and wrap_int do: a real answer would turn the variable you keep it in into a real, and the next place that wants a whole number would refuse it. Both numbers must be whole: modulo_int(x, 5) with a real x is refused when the project is checked. A b of 0 gives 0. A b below 0 counts as its size.